package org.example.new_hbps_backend_reconstruction.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.new_hbps_backend_reconstruction.entity.PatientBmiManaEntity;

import java.util.List;
import java.util.Map;

/**
 * @author 丁利军
 * @date 2025年10月11日 15:30
 * @description TODO: 描述
 */

@Mapper
public interface PatientBmiManaMapper extends BaseMapper<PatientBmiManaEntity> {

    @Select("SELECT height, weight, bmimeasurement_date " +
            "FROM patient_bmi_mana " +
            "WHERE patient_uid = #{patientUid} " +
            "ORDER BY bmimeasurement_date DESC " +
            "LIMIT 1 ")
    Map<String, Object> getLatestHeightWeight(@Param("patientUid") Long patientUid);

    @Select("SELECT height, weight, bmimeasurement_date " +
            "FROM patient_bmi_mana " +
            "WHERE patient_uid = #{patientUid} " +
            "ORDER BY bmimeasurement_date DESC " +
            "LIMIT 7 ")
    List<Map<String, Object>> getLastestSevenBmiRecord(@Param("patientUid") Long patientUid);
}